// Test suite for the lily.js module
(function() {
     module('lily');

     test('Dependencies loaded', function() {
	 ok(lily._hasDependencies(), 'dependencies were loaded properly');
     });

     test('Define namespaces', function() {
	 lily.defineNamespace('lily.test.namespace');
	 deepEqual(lily.test.namespace, {}, 'lily.test.namespace should '
		     + 'be a newly created namespace {}');
	 ok(lily.test, 'lily.test should also be created in the proccess');
     });

     test('Define modules', function() {
	 lily.defineModule('test.stuff');
	 lily.defineModule('test.stuff', 'mono.');
	 lily.defineModule('test.stuff', null, 'test.mono');
	 deepEqual(lily.test.stuff, {}, 'lily.test.stuff should be a new '
		                          + 'module');
	 deepEqual(mono.test.stuff, {}, 'mono.test.stuff should be a new '
		                          + 'module');
	 deepEqual(lily.test.mono, {}, 'lily.test.mono should be a new '
		                         + 'module');
     });

     test('define temporary variable', function() {
	 window.testvar = null;
	 lily.testvar = "test";
	 lily.defineTemp('testvar', 2);
	 lily.defineTemp('testvar', 5, lily);
	 equal(window.testvar, 2, 'window.testvar should now be 2');
	 equal(lily.testvar, 5, 'lily.testvar should now be 5');
     });

     test('rever temporary variables', function() {
	 lily.revertTemp('testvar', window);
	 lily.revertTemp('testvar', lily);
	 deepEqual(window.testvar, null, 'window.testvar should have '
                 + 'been reseted to null.');
	 equal(lily.testvar, "test", 'lily.testvar should have been '
	         + 'reseted to "test"');
     });

     test('uniqueIDs', function() {
	 var last_id = -1, id;
	 for (var i = 0; i < 10; ++i) {
	     id = lily.uniqueID();
	     ok(Object.isNumber(id), 'lily.uniqueID() should always return'
		                     + ' a number');
	     ok(id > last_id, 'the generated id should be greater than the'
			      + 'last one');
	     id = last_id;
	 }
     });
}());